<?php

/**
 * File class
 *
 * @author Julot <andy.julot@gmail.com>
 * @since Tuesday, June 21, 2011. 02:29 PM
 */
class File extends Path {

	public function getSize() {
		return filesize($this->_path);
	}

	public function getSizeName() {
		$formatter = Yii::app()->numberFormatter;
		$size = $this->size;
		$gb = round(($size / 1073741824), 2);
		if ($gb >= 1) return $formatter->formatDecimal($gb) . '&nbsp;GB';
		$mb = round(($size / 1048576), 2);
		if ($mb >= 1) return $formatter->formatDecimal($mb) . '&nbsp;MB';
		$kb = round(($size / 1024), 2);
		if ($kb >= 1) return $formatter->formatDecimal($kb) . '&nbsp;KB';
		return $formatter->formatDecimal($size) . '&nbsp;B';
	}

}
